const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
  transpileDependencies: true,
  devServer: {
    port: 8082,
    client: {
      webSocketURL: 'ws://localhost:8082/ws',
    },
    // headers: {
    //   'Access-Control-Allow-Origin': '*',
    // },
    proxy: {
      '/word': {//请求前缀，有这个前缀(紧跟端口号)的才会走代理
        target: 'http://localhost:8081',
        // pathRewrite:{"^/word":""}, //pathRewrite的key写一个正则的匹配条件,匹配以test开头的路径，把test替换为空字符串
        ws: true,//用于支持websocket
        changeOrigin: true//是否对告诉真实服务器真实的源，false不改变源(真实的源) true(改变源)-----用于控制请求头中的host值
      },
      '/close': {
        target: 'http://localhost:8081',
        ws: true,
        changeOrigin: true
      },
      '/subject': {
        target: 'http://localhost:8081',
        ws: true,
        changeOrigin: true
      },
      '/question': {
        target: 'http://localhost:8081',
        ws: true,
        changeOrigin: true
      },
      '/exam': {
        target: 'http://localhost:8081',
        ws: true,
        changeOrigin: true
      },
      '/login': {
        target: 'http://localhost:8081',
        // target: 'https://v.api.aa1.cn/api/yiyan/index.php',
        pathRewrite:{"^/test":""},//pathRewrite的key写一个正则的匹配条件,匹配以test开头的路径，把test替换为空字符串
        ws: true,
        changeOrigin: true
      },
      '/test': {
        target: 'http://localhost:8081/exam/add',
        // target: 'https://v.api.aa1.cn/api/yiyan/index.php',
        pathRewrite:{"^/test":""},//pathRewrite的key写一个正则的匹配条件,匹配以test开头的路径，把test替换为空字符串
        ws: true,
        changeOrigin: true
      }
    }
  }
})
